﻿package mortal.game.view.copy.worldBoss.pannel
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import fl.data.*;
    import flash.utils.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.worldBoss.cellRender.*;
    import mortal.game.view.task.view.base.*;
    import mortal.mvc.core.*;

    public class WorldBossHoleContentPanel extends TaskViewContentPanel
    {
        private var txtTitle:GTextFiled;
        private var rankList:GTileList;
        private var txtMyGuildTitle:GTextFiled;
        private var bgMyGuild:ScaleBitmap;
        private var txtMyGuildContent:GTileList;
        private var itemList:GTileList;
        private var txtRewards:GTextFiled;
        private var bgRewards:ScaleBitmap;
        private var imgHLine:GBitmap;
        private var txtInfo:GTextFiled;
        private var controlsDy:Dictionary;

        public function WorldBossHoleContentPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.controlsDy = new Dictionary();
            this.txtTitle = UIFactory.gTextField(Language.getString(21429), 65, 1, 100, 18, this, GlobalStyle.textFormatAnjin, true);
            this.pushUIToDisposeVec(UIFactory.bg(0, 21, 208, 21, this, ImagesConst.RegionTitleBg));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(21423), 10, 21, 30, 20, this, GlobalStyle.textFormatBai));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(21430), 40, 21, 90, 20, this, GlobalStyle.textFormatHuang2.center()));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(21425), 130, 21, 80, 20, this, GlobalStyle.textFormatHuang2.center()));
            this.rankList = UIFactory.tileList(0, 46, 420, 385, this);
            this.rankList.rowHeight = 20;
            this.rankList.columnWidth = 420;
            this.rankList.horizontalGap = 1;
            this.rankList.verticalGap = 0;
            this.rankList.focusEnabled = false;
            this.rankList.setStyle("cellRenderer", WorldBossHoleRankCellRender);
            this.bgMyGuild = UIFactory.bg(0, 146, 208, 21, this, ImagesConst.RegionTitleBg);
            this.txtMyGuildTitle = UIFactory.gTextField(Language.getString(21431), 70, 146, 70, 20, this, GlobalStyle.textFormatHuang2);
            this.txtMyGuildContent = UIFactory.tileList(0, 172, 420, 385, this);
            this.txtMyGuildContent.rowHeight = 20;
            this.txtMyGuildContent.columnWidth = 420;
            this.txtMyGuildContent.horizontalGap = 1;
            this.txtMyGuildContent.verticalGap = 0;
            this.txtMyGuildContent.setStyle("cellRenderer", WorldBossHoleRankCellRender);
            this.imgHLine = UIFactory.bitmap(ImagesConst.worldBoss_hLine, 10, 195, this);
            this.txtInfo = UIFactory.gTextField("  " + Language.getString(80100), 10, 200, 190, 60, this, GlobalStyle.textFormatBai);
            this.txtInfo.wordWrap = true;
            this.bgRewards = UIFactory.bg(0, 255, 208, 21, this, ImagesConst.RegionTitleBg);
            this.txtRewards = UIFactory.gTextField(Language.getString(21432), 70, 255, 70, 20, this, GlobalStyle.textFormatHuang2);
            this.itemList = UIFactory.tileList(20, 280, 200, 43, this);
            this.itemList.rowHeight = 42;
            this.itemList.columnWidth = 42;
            this.itemList.horizontalGap = 1;
            this.itemList.verticalGap = 1;
            this.itemList.rowCount = 6;
            this.itemList.setStyle("cellRenderer", WorldBossHoleRewardCellRenderer);
            this.controlsDy[this.imgHLine] = this.imgHLine.y;
            this.controlsDy[this.txtInfo] = this.txtInfo.y;
            this.controlsDy[this.bgRewards] = this.bgRewards.y;
            this.controlsDy[this.txtRewards] = this.txtRewards.y;
            this.controlsDy[this.itemList] = this.itemList.y;
            this.updateItemList();
            Dispatcher.addEventListener(EventName.Scene_Update, this.updateItemList);
            return;
        }// end function

        public function updateItemList(param1 = null) : void
        {
            var _loc_3:Array = null;
            var _loc_4:int = 0;
            var _loc_5:DataProvider = null;
            var _loc_6:int = 0;
            var _loc_2:* = WorldBossConfig.instance.getWorldBossByMapId(MapFileUtil.mapID);
            if (_loc_2)
            {
                _loc_3 = _loc_2.bossDrop.split("#");
                _loc_4 = _loc_3.length;
                _loc_5 = new DataProvider();
                _loc_6 = 0;
                while (_loc_6 < _loc_4)
                {
                    
                    _loc_5.addItem(new ItemData(int(_loc_3[_loc_6])));
                    _loc_6++;
                }
                if (this.itemList && _loc_5 && _loc_5.length)
                {
                    this.itemList.dataProvider = _loc_5;
                    this.itemList.drawNow();
                }
            }
            return;
        }// end function

        override public function refresh(param1:Boolean = false) : void
        {
            var _loc_2:Array = null;
            var _loc_3:int = 0;
            var _loc_4:DataProvider = null;
            var _loc_5:Boolean = false;
            var _loc_6:int = 0;
            var _loc_7:* = undefined;
            var _loc_8:SWorldBossHurtRankInfo = null;
            var _loc_9:DataProvider = null;
            super.refresh(param1);
            if (!allowRefresh)
            {
                return;
            }
            if (Cache.instance.copy.worldBoss.worldBossHurtList)
            {
                _loc_2 = Cache.instance.copy.worldBoss.worldBossHurtList.topInfos;
                _loc_3 = _loc_2.length;
                _loc_4 = new DataProvider();
                _loc_5 = false;
                _loc_6 = 0;
                while (_loc_6 < _loc_3)
                {
                    
                    _loc_8 = _loc_2[_loc_6] as SWorldBossHurtRankInfo;
                    _loc_4.addItem(_loc_8);
                    if (Cache.instance.guild.hasGuild && _loc_8.guildName == Cache.instance.guild.selfGuildInfo.selfInfo.guildName)
                    {
                        _loc_5 = true;
                    }
                    _loc_6++;
                }
                if (_loc_3 > 1)
                {
                    _loc_9 = new DataProvider();
                    _loc_9.addItem(_loc_4.removeItemAt((_loc_3 - 1)));
                    this.txtMyGuildContent.dataProvider = _loc_9;
                    this.txtMyGuildContent.drawNow();
                    for (_loc_7 in this.controlsDy)
                    {
                        
                        _loc_7["y"] = this.controlsDy[_loc_7];
                    }
                    var _loc_10:Boolean = true;
                    this.txtMyGuildContent.visible = true;
                    var _loc_10:* = _loc_10;
                    this.txtMyGuildTitle.visible = _loc_10;
                    this.bgMyGuild.visible = _loc_10;
                }
                this.rankList.dataProvider = _loc_4;
                this.rankList.drawNow();
            }
            return;
        }// end function

        override public function get titleLabel() : GTextFiled
        {
            return this.txtTitle;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            Dispatcher.removeEventListener(EventName.Scene_Update, this.updateItemList);
            this.txtTitle = this.txtTitle && this.txtTitle.dispose(param1) ? (null) : (null);
            this.rankList = this.rankList && this.rankList.dispose(param1) ? (null) : (null);
            this.txtMyGuildTitle = this.txtMyGuildTitle && this.txtMyGuildTitle.dispose(param1) ? (null) : (null);
            this.bgMyGuild = this.bgMyGuild && this.bgMyGuild.dispose(param1) ? (null) : (null);
            this.itemList = this.itemList && this.itemList.dispose(param1) ? (null) : (null);
            this.txtRewards = this.txtRewards && this.txtRewards.dispose(param1) ? (null) : (null);
            this.bgRewards = this.bgRewards && this.bgRewards.dispose(param1) ? (null) : (null);
            this.imgHLine = this.imgHLine && this.imgHLine.dispose(param1) ? (null) : (null);
            this.txtInfo = this.txtInfo && this.txtInfo.dispose(param1) ? (null) : (null);
            this.txtMyGuildContent = this.txtMyGuildContent && this.txtMyGuildContent.dispose(param1) ? (null) : (null);
            this.controlsDy = null;
            super.disposeImpl(param1);
            return;
        }// end function

    }
}
